package com.jing.service.impl;

import com.jing.common.core.exception.ServiceException;
import com.jing.domain.Vo.ProducAttributetCategoryVO;
import com.jing.domain.po.ProducAttributetCategoryPO;

import com.jing.mapper.ProducAttributetCategorymapper;
import com.jing.service.ProducAttributetCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;

/**
 * @Author：wp
 * @Package：com.jing.service.impl
 * @Project：jing
 * @name：ProducAttributetCategoryimpl
 * @Date：2024/5/24 11:28
 */
@Service
@Slf4j
public class ProducAttributetCategoryimpl implements ProducAttributetCategoryService {
    @Autowired
    private ProducAttributetCategorymapper producAttributetCategorymapper;

    @Override
    public List<ProducAttributetCategoryVO> list() {
        ProducAttributetCategoryVO vos = new ProducAttributetCategoryVO ();
        List<ProducAttributetCategoryPO> list=producAttributetCategorymapper.list();
        if(vos.getPageSize () > list.size () ||vos.getPageNum () > list.size () ){
            return null;
        }
        ArrayList<ProducAttributetCategoryVO> arrayList = new ArrayList<> ();
        for (ProducAttributetCategoryPO producAttributetCategoryPO : list) {
            ProducAttributetCategoryVO vo = new ProducAttributetCategoryVO ();
            BeanUtils.copyProperties(producAttributetCategoryPO,vo);
            arrayList.add ( vo );
        }

        return arrayList;
    }
    @Override
    public void add(String name) {
        ProducAttributetCategoryPO po = new ProducAttributetCategoryPO ();
        po.setName (name);
        producAttributetCategorymapper.add(po);
    }
    @Override
    public void up(ProducAttributetCategoryVO producAttributetCategoryVO) {
        ProducAttributetCategoryPO po = new ProducAttributetCategoryPO ();
        BeanUtils.copyProperties ( producAttributetCategoryVO,po );
        producAttributetCategorymapper.up(po);
    }
    @Override

    public void del(Integer id) {
        producAttributetCategorymapper.del(id);
    }
}
